package dda;

import java.io.Serializable;
import java.util.Random;

public class Mobiel implements Comparable, Serializable {
	private String merk;
	private Integer serienummer;
	private int lengteArray = 10;
	Random r = new Random();

	public static void main(String[] args) {
		Mobiel m = new Mobiel();
		m.generateRandomMobieltjes();
	}

	public int compareTo(Object o) {
		if (o instanceof Mobiel) {
			Mobiel obj = (Mobiel) o;
			return this.serienummer.compareTo(obj.serienummer);
		}
		return -1;
	}

	private Mobiel[] generateRandomMobieltjes() {
		Mobiel mobieltjes[] = new Mobiel[lengteArray];
		int wordSize;
		for (int i = 0; i < lengteArray; i++) {
			mobieltjes[i] = new Mobiel();
			mobieltjes[i].serienummer = r.nextInt(10000);
			
			wordSize = r.nextInt(10);
			   while(wordSize == 0){
			    wordSize = r.nextInt(10);
			   }
			char[] word = new char[wordSize];
			String generatedMerk;
			for (int i1 = 0; i1 < wordSize; i1++) {
				int randomNo = r.nextInt(255);
				word[i1] = (char) randomNo;
				while ((randomNo < 65 ^ randomNo > 90)) {
					randomNo = r.nextInt(255);
					word[i1] = (char) randomNo;
				}
			}
			generatedMerk = new String(word);
			mobieltjes[i].merk = generatedMerk;
			System.out.println("merknaam = " + mobieltjes[i].merk);
			System.out.println("Serienummer = " + mobieltjes[i].serienummer);

		}
		return mobieltjes;

	}

}